<?php

/**
 * This is the model class for table "tbl_terms".
 *
 * The followings are the available columns in table 'tbl_terms':
 * @property integer $termid
 * @property string $term
 * @property double $type
 * @property double $netdue
 * @property double $paidwithin
 * @property double $netdueday
 * @property double $nxtmoday
 * @property double $discday
 * @property double $discount
 */
class Terms extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Terms the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_terms';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('term, type, netdue, paidwithin, netdueday, nxtmoday, discday, discount', 'required'),
			array('type, netdue, paidwithin, netdueday, nxtmoday, discday, discount', 'numerical'),
			array('term', 'length', 'max'=>31),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('termid, term, type, netdue, paidwithin, netdueday, nxtmoday, discday, discount', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'termid' => 'Termid',
			'term' => 'Term',
			'type' => 'Type',
			'netdue' => 'Netdue',
			'paidwithin' => 'Paidwithin',
			'netdueday' => 'Netdueday',
			'nxtmoday' => 'Nxtmoday',
			'discday' => 'Discday',
			'discount' => 'Discount',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('termid',$this->termid);
		$criteria->compare('term',$this->term,true);
		$criteria->compare('type',$this->type);
		$criteria->compare('netdue',$this->netdue);
		$criteria->compare('paidwithin',$this->paidwithin);
		$criteria->compare('netdueday',$this->netdueday);
		$criteria->compare('nxtmoday',$this->nxtmoday);
		$criteria->compare('discday',$this->discday);
		$criteria->compare('discount',$this->discount);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}